<?php

namespace app\models\merchant;

use app\models\constant\Status;
use app\models\Images;
use Yii;

/**
 * This is the model class for table "merchant_type".
 *
 * @property int $id
 * @property string $name
 * @property int $sort
 * @property int $image_id
 */
class MerchantType extends \yii\db\ActiveRecord
{
    use Status;

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'merchant_type';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['sort', 'image_id'], 'integer'],
            [['name'], 'string', 'max' => 255],

            [['status'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'sort' => 'Sort',
            'image_id' => 'Image ID',
        ];
    }

    public function getImage()
    {
        return $this->hasOne(Images::class, ['id' => 'image_id']);
    }
}
